﻿@namespace BootstrapBlazor.Components
@inherits ComponentBase

@{
    var renderFileUpload = RenderUploadInfo.RenderFileUploadInfo;
    var uploadTaskInfo = renderFileUpload.UploadTaskInfo;
    var hugeFileCount = uploadTaskInfo.HugeFiles.Count;
}
<div class="commonContainers">
    <div class="compactCentered">
        <label>
            <InputFile OnChange="renderFileUpload.OnChange" id="@renderFileUpload.ID" @key=@renderFileUpload.ID
                       accept="@RenderUploadInfo.Accept" multiple="@RenderUploadInfo.Multiple" />
            <span class="uploadButtonContainer">
                <Button Text="@RenderUploadInfo.UploadButtonText" />
                @if (RenderUploadInfo.InUpload)
                {
                    <Spinner Color="Color.Primary" />
                }
            </span>
        </label>
        @if (uploadTaskInfo.UploadFileOptions.EnableClipboardUpload)
        {
            <Button Text="粘贴图片" OnClick="@RenderUploadInfo.OnUploadFromClipboard" />
        }
    </div>
    <div>
        @if (RenderUploadInfo.ShowPrompt)
        {
            <div>提示：点击即可删除文件，上传文件的最大大小为@(uploadTaskInfo.UploadFileOptions.MaxAllowedSizeFormat)</div>
        }
        @if (hugeFileCount > 0)
        {
            <div class="emphasizeText">有@(hugeFileCount)个文件因为大小超过限制，未能上传</div>
        }
    </div>
</div>